package controller;

import pojo.User;
import service.IUserService;
import service.ServiceFactory;
import vo.ResponseVo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

public class UserController {
    private IUserService iUserService = ServiceFactory.getIntance("UserService");

    /**
     * 获取所有用户信息列表
     * @param request
     * @param response
     * @return
     */
    public ResponseVo<List<User>> getUserList(HttpServletRequest request, HttpServletResponse response){
        //调用相应的service处理用户的请求
        // /UserController/getUserList
        return iUserService.getUserList();
    }

    /**
     * 根据id查询用户信息
     * @param request
     * @param response
     * @return
     */
    public ResponseVo<User> findUserById(HttpServletRequest request, HttpServletResponse response){
        String id = request.getParameter("id");
        //调用相应的service处理用户的请求
        // /UserController/findUserById?id=
        return iUserService.findUserById(Integer.parseInt(id));
    }

}
